package Model;

public class LoginCredential {

    private int username;
    private String password;

    public LoginCredential(int username, String password){
        this.username = username;
        this.password = password;
    }

    public int getIntegerUsername(){
        return this.username;
    }

    public String getFormattedUserName(){
        String uName = ""+getIntegerUsername();
        return uName.substring(0,3)+"-"+uName.substring(3);
    }

    public String getPassword(){
        return this.password;
    }

    public static int sanitizedUsernameCheck(String username){
        if (username.length() == 8 && username.contains("-")) {
            String[] usernameSplit = username.split("-");
            String sanitizedUsername = usernameSplit[0].trim() + usernameSplit[1].trim();
            return Integer.parseInt(sanitizedUsername);
        }
        else
            return -1;
    }

    public boolean equals(LoginCredential loginCredential){
        return ((loginCredential.getIntegerUsername() == this.username)
                && (loginCredential.getPassword().equals(this.password)));
    }

}
